layui.define([ 'form', 'laydate', 'table' ,'scoreStatApi'], function(exports) {
	var form = layui.form;
	var laydate = layui.laydate;
	var table = layui.table;
    var scoreStatApi=layui.scoreStatApi;
	var rechargeTable = null;
	
	var view ={
		
		init:function(){
			this.initTable();
			this.initSearchForm();
			this.initToolBar();
			window.dataReload = function(){
				Lib.doSearchForm($("#searchForm"),rechargeTable)
			}
			
			
		},
		initTable:function(){
			rechargeTable = table.render({
				elem : '#rechargeTable',
				height : Lib.getTableHeight(2),
				method : 'post',
				url : Common.ctxPath + '/admin/scoreStat/list.json' //数据接口
				,page : Lib.tablePage //开启分页
				,limit : 10,
				cols : [ [ //表头
				{
					type : 'checkbox',
					fixed:'left',
				}, {
					field : 'openid',
					title : '用户ID',
					width : 240,
					fixed:'center',
					sort : true
				}, {
					field : 'nickname',
					title : '微信昵称',
					width : 180
				},{
					field : 'score',
					title : '透镜分数',
					width : 140
				}

				] ]

			});
		},
		
		initSearchForm:function(){
			Lib.initSearchForm( $("#searchForm"),rechargeTable,form);
		},
		initToolBar:function(){
        	toolbar = {
                exportScoreStat:function(){
                    Common.openConfirm("确认要导出云币汇总统计信息?",function(){
                        scoreStatApi.exportScoreStat($("#searchForm"),function(fileId){
                            Lib.download(fileId);
                        })
                    })

                }
        		};
        	$('.ext-toolbar').on('click', function() {
        		var type = $(this).data('type');
        		toolbar[type] ? toolbar[type].call(this) : '';
        	});
        }
	}

		 exports('index',view);
	
});